/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ApacheClient;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

/**
 *
 * @author Chris
 */
public class ApacheClient {
    private HttpClient httpclient = new DefaultHttpClient();

    public void getPage(String urltext, String location) throws IOException {
        HttpGet httpget = new HttpGet(urltext);
        HttpResponse response = httpclient.execute(httpget);
        FileOutputStream out = new FileOutputStream(location);
        response.getEntity().writeTo(out);
        out.close();
    }

    public InputStream getPage(String urltext) throws IOException {
        HttpGet httpget = new HttpGet(urltext);
        HttpResponse response = httpclient.execute(httpget);
        return response.getEntity().getContent();
    }
}
